package com.code.monitor.service.impl;

import com.code.monitor.conditions.MemoryRuntimeCondition;
import com.code.monitor.model.CacheManager;
import com.code.monitor.model.PackageInfo;
import com.code.monitor.service.PackageService;
import org.springframework.context.annotation.Conditional;
import org.springframework.stereotype.Service;

import java.util.Collection;

@Conditional(MemoryRuntimeCondition.class)
@Service
public class MemoryPackageServiceImpl implements PackageService {
    @Override
    public void addPackage(PackageInfo packageInfo) {
        CacheManager.addPackageInfo(packageInfo);
    }

    @Override
    public void delPackage(String uuid) {
        CacheManager.delPackageInfo(uuid);
    }

    @Override
    public Collection<PackageInfo> queryAllPackage() {
        return CacheManager.getPackageInfoList();
    }

    @Override
    public PackageInfo queryPackageByUUID(String uuid) {
        return CacheManager.getPackageInfo(uuid);
    }
}
